/**
 * @author : wangbo
 * @date : 2020-11-01 17:20
 **/
package com.ohaku.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class DragonInterceptor implements HandlerInterceptor {

    private static final Logger logger = LoggerFactory.getLogger(DragonInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
        logger.info(request.getRequestURI());

        if (request.getRequestURI().equals("/v1/api/dragon/name")) {
            return true;
        }

        response.sendRedirect("/v1/api/dragon/name");
        return false;
    }
}